<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var findOriginalArray = function (arr) {
      if (arr.length & 1) return [];
      arr.sort((a, b) => a - b);
      const map = {}, ans = [];
      for (const num of arr) map[num] = (map[num] || 0) + 1;
      for (const num of arr) {
        if (!map[num]) continue;
        if (!map[num * 2]) return [];
        map[num]--, map[num * 2]--;
        ans.push(num);
      }
      return ans;
    };
    console.log(findOriginalArray([1, 3, 4, 2, 6, 8]));
  </script>
</body>

</html>